home *** CD-ROM | disk | FTP | other *** search
- /* Taken from original script by Matthias Finger
- Modified by Sébastien Boisvert for general use
- Version 1.9 September 9 1998 */
-
- /* Options */
-
- PATTERN = "~#?.(htm#?|info)" /* file pattern to match/exclude (standard AmigaDOS patterns allowed) */
- BORDER=1 /* border width for the table */
- GFXCON="work:images/gfxcon/GfxCon" /* Path for GfxCON */
- FORMAT="gif" /* Format for destination picture (lower case!) uncomment next line for JPEG */
- /* FORMAT="jpeg" */
- QUALITY=85 /* Quality for jpeg destination */
- VERBOSE=1 /* GfxCon Verbose output: 1=OFF, 0=ON */
- BASE='' /* Inserted in index file(s); put <BASE HREF=xxx> if you store your pictures elsewhere */
- PBASE='' /* Inserted in picture page file(s); put <BASE HREF=xxx> if you store your pictures elsewhere */
- HEADER='' /* Header, inserted at top of page (after BODY tag) */
- FOOTER='' /* Footer, inserted at bottom of page (before /BODY tag) */
- PHEADER='' /* Picture page Header, inserted at top of page (after BODY tag) */
- PFOOTER='' /* Picture page Footer, inserted at bottom of page (before /BODY tag) */
-
- sizex=100 /* default values for arguments */
- sizey=100
- dest="thumb"
- perpage=0
- res=800
- picpage=0
- /* ------- You should know what you do, if you change anything below -------- */
-
- signal on error
- signal on BREAK_C
-
- Say "Thumbnail 1.9 by Sébastien Boisvert"'0a'x
-
- if ~show("L","rexxsupport.library") then
- if ~ addlib("rexxsupport.library",0,-30,0) then do
- say "Cannot open rexxsupport.library!"
- exit 10
- end
-
- if ~show("L","rexxarplib.library") then
- if ~addlib("rexxarplib.library",0,-30,2) then do
- say "Need rexxarplib.library!"
- exit 10
- end
-
- if ~show("L","rexxdossupport.library") then
- if ~addlib("rexxdossupport.library",0,-30,0) then do
- say "Need rexxdossupport.library!"
- exit 10
- end
-
- template="SIZEX/N,SIZEY/N,DEST/K,PERPAGE/N,RES/N,PATTERN/K,PICPAGE/S"
-
- parse arg args
- if arg(1)=="?" | ~Readargs(args,template) then signal usage
-
- /* put proper extensions on the format; remove 'E' form 'JPEG' */
- form="."||format
- form=compress(form,"e")
-
- files=filelist(PATTERN,filenames,F,) /* make file list */
-
- if (files==0) then do
- say "No files to process!"
- exit 0
- end
-
- if ~exists(dest) then
- call makedir(dest) /* check if directory exists and create it if not */
-
- dest=dest||"/"
-
- call sort()
- say "Checking for new pictures..."
-
- do f=1 to files
- name= filenames.f
-
-
- call pragma("STACK",22000)
-
- parse var name file "." .
- names.f="t_"||file||FORM
- if ~exists(dest||names.f) then do /* if thumbnail doesn't exists... */
- comm = GFXCON||' "'||name'"'
- IF(VERBOSE==1) THEN do
- comm = comm||' >NIL:'
- say "Processing file "name /* make one */
- end
- comm = comm||' TO "'||dest||names.f||'" FORMAT 'FORMAT
- IF (UPPER(FORM)==".JPG") THEN DO
- comm = comm||' QUALITY 'QUALITY||' '
- END
- comm = comm||' BOXFIT '||sizex||' '||sizey
- ADDRESS COMMAND comm /* make up command line and execute it */
- end
- if ~exists(dest||names.f) then say " Error - GfxCon could not create a thumbnail!"
- END
-
- /* create thumbnail table */
-
- if res="" then res=800 /* resolution; 800 for X default */
-
- if perpage ==0 then perpage=files
-
- number=1
- pagefiles=perpage
-
- pages=files%perpage
- if files//perpage ~=0 then pages=pages+1
-
- line="0a"x||"Creating "pages" index page"
- if pages>1 then line=line||"(s)"
- if picpage==1 then line=line||" and "files" picture pages"
- say line||"0a"x
-
- do p=1 to pages
-
- if files-(perpage*p)<0 then pagefiles=files//perpage
-
- if pagefiles>0 then do
- max = res % ((border*2)+sizex+7) /* get maximum number of thumbnails that fit on one row */
-
- if (pagefiles//max) ~=0 then do /* if all thumbnails don't fit all equally */
- mostremainders=pagefiles//max
- do temp=max to 2 by -1 /* figure out how many across will produce the least */
- if pagefiles//temp > mostremainders then do /* amount of blank spaces in last row */
- mostremainders=pagefiles//temp
- max=temp
- end
- end
- end
-
- rows = pagefiles%max
- if pagefiles//max ~=0 then rows=rows+1
-
- indexfile="output"
- if open(indexfile,"t_index"||p||".html","W") then do
- say "Creating index page #"||p||"..." /* Create the index page */
-
- call writeln(indexfile,"<HTML>") /* Put the code in */
- call writeln(indexfile,"<BODY>")
- call writeln(indexfile,BASE)
- call writeln(indexfile,HEADER)
- call writeln(indexfile,"<CENTER>"||"0a"x||"<BR>")
-
- line=''
- do f=1 to pages
- if f==p then
- line=line||'<A HREF=t_index'||f||'.html><B>'||f||' </B></A>'
- else
- line=line||'<A HREF=t_index'||f||'.html>'||f||' </A>'
- end
- if pages>1 then call writeln(indexfile,line||"0a"x||"<BR>")
-
- call writeln(indexfile,"<TABLE BORDER="||border||">")
-
- call pragma("STACK",22000)
-
- do rows /* do the tables */
- call writeln(indexfile,"<TR ALIGN=CENTER>")
- do max
- if number-(perpage*(p-1))>pagefiles then iterate
-
- comm=GFXCON||' >T:thumbinfo "'||dest||names.number||'" info'
- fileinfo="fileinfo"
-
- address command comm
- call open(fileinfo,"T:thumbinfo","r")
- do 4
- info=readln(fileinfo)
- end
- parse var info "input size: " thumbx "x" thumby .
- call close(fileinfo)
- if picpage then call writeln(indexfile," <TD><A HREF="||filenames.number||".html><IMG SRC="||dest||names.number||" ALT="||filenames.number||" WIDTH="||thumbx||" HEIGHT="||thumby||" BORDER=0></A></TD>")
- else
- call writeln(indexfile," <TD><A HREF="||filenames.number||"><IMG SRC="||dest||names.number||" ALT="||filenames.number||" WIDTH="||thumbx||" HEIGHT="||thumby||" BORDER=0></A></TD>")
-
- if picpage then do /* Create picture page */
- line1=''
- if open(picfile,filenames.number||".html","W") then do /* Create picture page */
- call writeln(picfile,"<HTML>") /* Put the code in */
- call writeln(picfile,"<BODY>")
- call writeln(picfile,PBASE)
- call writeln(picfile,PHEADER)
- call writeln(picfile,"<CENTER>"||"0a"x||"<BR>")
-
- comm=GFXCON||' >T:thumbinfo '||filenames.number||' info'
- fileinfo="fileinfo"
-
- address command comm
- call open(fileinfo,"T:thumbinfo","r")
- do 4
- info=readln(fileinfo)
- end
- parse var info "input size: " thumbx "x" thumby .
- call close(fileinfo)
-
- call writeln(picfile,"<IMG SRC="||filenames.number||" WIDTH="||thumbx||" HEIGHT="||thumby||"><BR><PRE>")
-
- prev=number-1; next=number+1
- if number>1 then line1="<A HREF="filenames.prev||".html>Previous</A> "
- if number<files then line1=line1||'<A HREF='||filenames.next||'.html>Next</A>'
- call writeln(picfile,line1||"<BR></PRE>")
- call writeln(picfile,"Index: "||line)
- call writeln(picfile,"</CENTER>") /* close off the HTML document */
- call writeln(picfile,PFOOTER)
- call writeln(picfile,"</BODY>")
- call writeln(picfile,"</HTML>")
- call close (picfile)
- end
- else say " Cannot create picture page file for "||filenames.number||"!"
- end
- number=number+1
- end
- call writeln(indexfile,"</TR>")
- end
-
- call writeln(indexfile,"</TABLE>")
- if pages>1 then call writeln(indexfile,line||"0a"x||"<BR>")
- call writeln(indexfile,"</CENTER>") /* close off the HTML document */
- call writeln(indexfile,FOOTER)
- call writeln(indexfile,"</BODY>")
- call writeln(indexfile,"</HTML>")
- call close (indexfile)
- end
- end
- else
- say " Cannot create index file!!!"
- end
- call delete("T:thumbinfo")
- say "0a"x||"Done."
-
- exit
-
- /* Sort routine */
-
- SORT: procedure expose filenames. files
- say "Sorting list of files..."
-
- do f=1 to files-1
- n=f+1
- if filenames.f > filenames.n then
- do
- store=filenames.n
- filenames.n=filenames.f
-
- do bubpos=f-1 to 1 by -1 while (store < filenames.bubpos)
- n=bubpos+1
- filenames.n=filenames.bubpos
- end bubpos
-
- bubpos=bubpos+1
- filenames.bubpos=store
- end
- end f
- return
-
- error:
- BREAK_C:
- if exists("T:thumbinfo") then call delete("T:thumbinfo") /* clean up */
- exit 5
-
- usage:
- say "Usage: thumbnail SIZEX/N SIZEY/N DEST/K PERPAGE/N RES/N PATTERN/K PICPAGE/S"
- say " SIZEX & SIZEY - maximum sizes for thumbnail ["SIZEX"] ["SIZEY"]"
- say " DEST - directory to store thumbnails (no '/') ["DEST"]"
- say " PERPAGE - the maximum number of pictures per table ["PERPAGE"]"
- say " RES - intended page resolution ["RES"]"
- say " PATTERN - standard AmigaDOS pattern used to match files ["PATTERN"]"
- say " PICPAGE - if given will create an HTML page for each picture"
- exit
-